package com.infonam.data.source.model;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;


@Entity
@Table(name="staff", catalog="sakila")
public class Staff implements Serializable{
	private static final long serialVersionUID = 1L;
	private int id;
	private String first_name;
	private String last_name;
	private int address_id;
	private byte[] picture;
	private String email;
	private Store	store_id;
	private int active;
	private String username;
	private String password;
	private Date lastupdate;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="staff")
	@Cascade({CascadeType.ALL})
	private List<Store> stores = new LinkedList<Store>();
	@OneToMany(fetch=FetchType.LAZY,mappedBy="staff")
	@Cascade({CascadeType.ALL})
	private List<Rental> rentals = new LinkedList<Rental>();
	@OneToMany(fetch=FetchType.LAZY,mappedBy="staff")
	@Cascade({CascadeType.ALL})
	private List<Payment> payments = new  LinkedList<Payment>();
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name ="id",unique=true,nullable=false)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	@Column(name="first_name",nullable=false)
	public String getFirst_name() {
		return first_name;
	}
	public void setFirst_name(String first_name) {
		this.first_name = first_name;
	}
	@Column(name="last_name",nullable=false)
	public String getLast_name() {
		return last_name;
	}
	public void setLast_name(String last_name) {
		this.last_name = last_name;
	}
	@Column(name="address_id",nullable=false)
	public int getAddress_id() {
		return address_id;
	}
	public void setAddress_id(int address_id) {
		this.address_id = address_id;
	}
	@Column(name="picture",nullable=true)
	public byte[] getPicture() {
		return picture;
	}
	public void setPicture(byte[] picture) {
		this.picture = picture;
	}
	@Column(name="email",nullable=true,length=254)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@ManyToOne
	@JoinColumn(name="store_id", nullable=false)
	public Store getStore_id() {
		return store_id;
	}
	public void setStore_id(Store store_id) {
		this.store_id = store_id;
	}
	@Column(name="active",nullable=false)
	public int getActive() {
		return active;
	}
	public void setActive(int active) {
		this.active = active;
	}
	@Column(name="username",nullable=false,length=254)
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@Column(name="password",nullable=false,length=50)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_update",nullable=false,columnDefinition="TIMESTAMP default CURRENT_TIMESTAMP on update TIMESTAMP")
	public Date getLastupdate() {
		return lastupdate;
	}
	public void setLastupdate(Date lastupdate) {
		this.lastupdate = lastupdate;
	}
	public List<Store> getStores() {
		return stores;
	}
	public void setStores(List<Store> stores) {
		this.stores = stores;
	}
	public List<Rental> getRentals() {
		return rentals;
	}
	public void setRentals(List<Rental> rentals) {
		this.rentals = rentals;
	}
	public List<Payment> getPayments() {
		return payments;
	}
	public void setPayments(List<Payment> payments) {
		this.payments = payments;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
